package tr.edu.ege.kipler.parsing;

import tr.edu.ege.kipler.syntax.BinaryBooleanExpression;
import tr.edu.ege.kipler.syntax.WorldElement;

/**
 * This class collects utility methods used in the ALC_BI grammer for Antlr.
 * 
 * @author Inanc Seylan
 * 
 */
class ParserUtility {
	/**
	 * This utility method traverses the input formula and if the currently
	 * visited formula is a boolean formula, it replaces the boolean operator to
	 * "and".
	 * 
	 * @param f The formula to be traversed
	 */
	public static void assignAndOperatorToBinarySubformulae(WorldElement f) {
		if (f instanceof BinaryBooleanExpression) {
			BinaryBooleanExpression bf = (BinaryBooleanExpression) f;
			bf.setOperator(BinaryBooleanExpression.Operator.AND);
			assignAndOperatorToBinarySubformulae(bf.getLhs());
			assignAndOperatorToBinarySubformulae(bf.getRhs());
		}
	}
}
